home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Installers / Smaller Installer 2.0.1 / Preinstalled version / Examples / Hook Procedure Examples / QD32Hook / QD32Hook.c next >
Encoding:
C/C++ Source or Header  |  1996-07-26  |  4.3 KB  |  150 lines  |  [TEXT/CWIE]

  1. /******************************************************************************
  2.     Smaller Installer © 1996 Bill Goodman, All Rights Reserved
  3. *******************************************************************************
  4.  
  5. Quickdraw Hook Example
  6.  
  7. This installer hook procedure checks that the target machine is running System
  8. 6.0.5 or higher. It also installs the 32-bit Quickdraw file if the target
  9. machine is not running version 1.2 or higher. The hook procedure installs the
  10. Quickdraw file by enabling installation group "P" so the installer will install
  11. the 32-bit Quickdraw file in the system folder.
  12.  
  13. To build this hook procedure, compile this code and create a code resource
  14. (Type:SICR, ID:501, non-preloaded, nonpurgeable, unlocked, unprotected,
  15. non-sysheap). Add this resource to the "QD32Hook.rsrc" file. Copy all the
  16. resources in "QD32Hook.rsrc" to your installer's resource file.
  17.  
  18. Add the 32-bit Quickdraw file to your source archive using the following path:
  19. "{P}:$EXTENSIONS:32-Bit QuickDraw"
  20.  
  21. ******************************************************************************/
  22.  
  23. // This file is compatible with version 2.1 of the universal headers
  24. #include <Dialogs.h>
  25. #include <GestaltEqu.h>
  26.  
  27. #ifdef __MWERKS__
  28. #include <A4Stuff.h>
  29. #endif
  30.  
  31. #ifdef THINK_C
  32. #include <SetUpA4.h>
  33. #endif
  34.  
  35. #include "SIHookProc.h"
  36.  
  37.  
  38. /******************************************************************************
  39.     Function Prototypes
  40. ******************************************************************************/
  41. void FirstFunction(void);
  42.  
  43.  
  44. /******************************************************************************
  45.     Constant Definitions
  46. ******************************************************************************/
  47. #define groupPMask        0x8000    // Group "P" selection mask
  48.  
  49. // Alert Definitions
  50. #define sysRequiredAlrt        500    // "This application requires version 6.0.5 or newer of the system software."
  51.  
  52.  
  53. /******************************************************************************
  54.     Variable Definitions
  55. ******************************************************************************/
  56. SIHookParmBlk *gParms;    // Global pointer to parameter block
  57.  
  58.  
  59. /*****************************************************************************/
  60. pascal void main(
  61.         SIHookParmBlk *parmBlk    // Pointer to parameter block
  62.         )
  63. /******************************************************************************
  64.     This is the main entry point for the installer hook procedure.
  65. ******************************************************************************/
  66. {
  67. #ifdef __MWERKS__
  68. long holdA4;
  69. #endif
  70.  
  71. // Set up access to global variables
  72. #ifdef THINK_C
  73. RememberA0();
  74. SetUpA4();
  75. #endif
  76.  
  77. #ifdef __MWERKS__
  78. holdA4 = SetCurrentA4();
  79. #endif
  80.  
  81. gParms = parmBlk;
  82.  
  83. switch (gParms->function)
  84.     {
  85.     case siHookFirst:
  86.         FirstFunction();
  87.     }
  88.  
  89. // Restore original A4 value
  90. #ifdef THINK_C
  91. RestoreA4();
  92. #endif
  93.  
  94. #ifdef __MWERKS__
  95. SetA4(holdA4);
  96. #endif
  97. }
  98.  
  99.  
  100. /*****************************************************************************/
  101. void FirstFunction(void)
  102. /******************************************************************************
  103.     Input parameters:
  104.         "targetVRefNum"    Volume reference number of target volume
  105.         "groupAPFlags"        Groups currently selected
  106.         "groupQUSel"
  107.         "groupVZSel"
  108.         "group32Flags"
  109.         "group64Flags"
  110.         "group96Flags"
  111.         "groupEnvironFlags"
  112.  
  113.     Returns:
  114.         "groupAPFlags"        Updated installation groups
  115.         "groupQUSel"
  116.         "groupVZSel"
  117.         "group32Flags"
  118.         "group64Flags"
  119.         "group96Flags"
  120.         "result"                Hook result code (siHookNoErr, siHookQuit)
  121.  
  122.     This function is called once when the installer is launched.
  123. ******************************************************************************/
  124. {
  125. long feature;
  126.  
  127. // Abort if target machine is not running system 6.0.5 or newer
  128. if (Gestalt(gestaltSystemVersion, &feature))
  129.     goto ForceQuit;    // Gestalt could not return system version - force quit
  130. if (feature < 0x0605)
  131.     {    // Newer system required - display alert then force installer to quit
  132.     StopAlert(sysRequiredAlrt, NULL);
  133.     goto ForceQuit;
  134.     }
  135. if (Gestalt(gestaltQuickdrawVersion, &feature))
  136.     goto ForceQuit;    // Gestalt could not return Quickdraw version - force quit
  137. if (feature < gestalt32BitQD12)
  138.     {    // Version is lower than 1.2 - enable installation group "P"
  139.     gParms->groupAPFlags |= groupPMask;
  140.     }
  141. else
  142.     {    // Version is 1.2 or higher - disable installation group "P"
  143.     gParms->groupAPFlags &= ~groupPMask;
  144.     }
  145. return;
  146.  
  147. // Error - force installer to terminate
  148. ForceQuit:
  149. gParms->result = siHookQuit;
  150. }